I've been on my discord bot for several days because I encountered a problem ...
I wanted to add the possibility of having a role following a reaction.
But it doesn't work as soon as I add the line to add the role, if I remove it it works fine.
code :
bot.on("messageReactionAdd", (reaction, member) => {
if(reaction.message.id === "894623823855493171"){
member.roles.add('892423129345978438');
reaction.message.channel.send(`Tu as réagi : ✅ ${member}`);
}
})
member is actually a User. The better way to do this is to get the GuildMember from the Guild. You can use GuildMemberManager.resolve
bot.on("messageReactionAdd", (reaction, user) => {
if(reaction.message.id === "894623823855493171"){
const member = reaction.guild.members.resolve(user)
member.roles.add('892423129345978438');
reaction.message.channel.send(`Tu as réagi : ✅ ${member}`);
}
})